package com.example.mybatis.controller;

import com.example.mybatis.model.User;
import com.example.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/selectAll")
    public List<User> selectAll() {
        return userService.selectAll();
    }

    @RequestMapping("/add")
    public int add(User user){
        return userService.add(user);
    }

    @RequestMapping("/update")
    public int updatePassword(int id,String password){
        return userService.updatePassword(id,password);
    }

    @RequestMapping("/delete")
    public int delete(int id){
        return userService.delete(id);
    }
}
